package com.bafa.objects;

import com.bafa.services.RetrieveServices;
import com.bafa.util.WebsiteUtils;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;

public class Match {
    protected HashMap addedScores = new HashMap();
    private boolean awayAdded;
    protected boolean blocked;
    protected boolean confirmed;
    private String cupRoundNameA;
    private String cupRoundNameB;
    protected Date date = new Date();
    protected int division;
    private int goalsA;
    private int goalsB;
    private boolean homeAdded;
    private int ID;
    protected boolean played;
    private boolean resultDue;
    private HashMap scorersA = new HashMap();
    private HashMap scorersB = new HashMap();
    private int seasonId;
    private int teamA;
    private String teamAName;
    private int teamB;
    private String teamBName;
    protected String time;
    protected boolean walkover;
   private Calendar cal;
    public Match() {
    }

    public void addScorersA(String scorer,int goals){
            
            this.scorersA.put(scorer,goals);
    }

    public void addScorersB(String scorer,int goals){
        
            this.scorersB.put(scorer,goals);
    }

    public String awayTeamName(){
        if(teamBName==null){
           return RetrieveServices.getTeam(teamB+"").getName();
        }else{
            return teamBName;
        }
    }

    public String dateOfMatch(){
            if(date==null) return "";
            return dayOfWeek()+" "+day()+" "+month()+" "+year();
    }
    public int day(){
            return date.getDate();
    }

    public String dayOfWeek(){
            return WebsiteUtils.getDayOfWeek(date.getDay());
    }

    public HashMap getAddedScores() {
        return addedScores;
    }

    public String getCupRoundNameA() {
        return cupRoundNameA;
    }

    public String getCupRoundNameB() {
        return cupRoundNameB;
    }

    public Date getDate() {
        return date;
    }

    public int getDivision() {
        return division;
    }

    public int getGoalsA() {
        return goalsA;
    }

    public int getGoalsB() {
        return goalsB;
    }

    public int getID() {
        return ID;
    }

    public HashMap getScorersA() {
        return scorersA;
    }

    public HashMap getScorersB() {
        return scorersB;
    }

    public int getSeasonId() {
        return seasonId;
    }

    public int getTeamA() {
        return teamA;
    }

    public String getTeamAName() {
       
        return teamAName;
    }

    public int getTeamB() {
        return teamB;
    }

    public String getTeamBName() {
        
        return teamBName;
    }

    public String getTime() {
        return time;
    }

    public String homeTeamName(){
        if(teamAName==null){
           return RetrieveServices.getTeam(teamA+"").getName();
        }else{
            return teamAName;
        }
    }

    public boolean isAwayAdded() {
        return awayAdded;
    }

    public boolean isBlocked() {
        return blocked;
    }

    public boolean isConfirmed() {
        return confirmed;
    }

    public boolean isHomeAdded() {
        return homeAdded;
    }

    public boolean isPlayed() {
        return played;
    }

    public boolean isResultDue() {
        return resultDue;
    }

    public boolean isWalkover() {
        return walkover;
    }

    public String month(){
            return WebsiteUtils.getMonth(date.getMonth());
    }

    public boolean resultDue(){
            Date today = new Date();
            if(date!=null&&date.before(today)){
                    return !isPlayed()&&!isBlocked();
            }else{
                    return false;
            }
            
    }

    public String[] scorersA(){
            return (String[])scorersA.keySet().toArray(new String[scorersA.size()]);
    }

    public String[] scorersB(){
            return (String[])scorersB.keySet().toArray(new String[scorersB.size()]);
    }

    public void setAddedScores(HashMap addedScores) {
        this.addedScores = addedScores;
    }

    public void setAwayAdded(boolean awayAdded) {
        this.awayAdded = awayAdded;
    }

    public void setBlocked(boolean blocked) {
        this.blocked = blocked;
    }

    public void setConfirmed(boolean confirmed) {
        this.confirmed = confirmed;
    }

    public void setCupRoundNameA(String cupRoundNameA) {
        this.cupRoundNameA = cupRoundNameA;
    }

    public void setCupRoundNameB(String cupRoundNameB) {
        this.cupRoundNameB = cupRoundNameB;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setDivision(int division) {
        this.division = division;
    }

    public void setGoalsA(int goalsA) {
        this.goalsA = goalsA;
    }

    public void setGoalsB(int goalsB) {
        this.goalsB = goalsB;
    }

    public void setHomeAdded(boolean homeAdded) {
        this.homeAdded = homeAdded;
    }

    public void setID(int iD) {
        this.ID = iD;
    }
    
    public void setPlayed(boolean played) {
        this.played = played;
    }
    
    public void setResultDue(boolean resultDue) {
        this.resultDue = resultDue;
    }
    
    public void setScorersA(HashMap scorersA) {
        this.scorersA = scorersA;
    }

    public void setScorersB(HashMap scorersB) {
        this.scorersB = scorersB;
    }
    
    public void setSeasonId(int seasonId) {
        this.seasonId = seasonId;
    }
    
    public void setTeamA(int teamA) {
        this.teamA = teamA;
    }
    
    public void setTeamAName(String teamAName) {
        this.teamAName = teamAName;
    }
    
    public void setTeamB(int teamB) {
        this.teamB = teamB;
    }
    
    public void setTeamBName(String teamBName) {
        this.teamBName = teamBName;
    }
    
    public void setTime(String time) {
        this.time = time;
    }
    
    public void setWalkover(boolean walkover) {
        this.walkover = walkover;
    }
    
    public int year(){
            return date.getYear();
    }

	public Calendar getCal() {
		return cal;
	}

	public void setCal(Calendar cal) {
		this.cal = cal;
	}
}
